package com.dy.drp.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dy.drp.dto.BuyinfoDto;
import com.dy.drp.dto.ClientCollect;
import com.dy.drp.entity.Cargo;
import com.dy.drp.mapper.SaleinfoMapper;
import com.dy.drp.service.ISaleinfoService;
import com.dy.drp.util.PageUtil;
import com.dy.drp.util.SelectUtil;
import com.dy.drp.vo.SaleinfoVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author dy
 * @since 2022-04-01
 */
@RestController
@RequestMapping("/saleinfo")
@Api(tags="销售信息接口")
public class SaleinfoController {
    @Autowired
    private ISaleinfoService saleinfoService;

    @GetMapping("/selectSaleInfo/{pageNum}/{pageSize}")
    @ApiOperation("查询单页出库信息/库存一览")
    @ApiImplicitParams({
            @ApiImplicitParam(name="pageNum",value="当前页码"),
            @ApiImplicitParam(name="pageSize",value="页面条数")
    })
    public PageUtil<SaleinfoVo> selectSaleInfo(@PathVariable("pageNum")Integer pageNum,
                                              @PathVariable("pageSize")Integer pageSize){
        PageUtil<SaleinfoVo> pageUtil = new PageUtil<>();
        pageUtil.setPageNum(pageNum);
        pageUtil.setPageSize(pageSize);
        return saleinfoService.selectOnePageSaleinfo(pageUtil);
    }

    @PostMapping("/selectByClientAndTime")
    @ApiOperation("查询出库信息")
    public PageUtil<SaleinfoVo> selectByClientAndTime(SelectUtil selectUtil){
        return saleinfoService.selectByClientAndTime(selectUtil);
    }

    @GetMapping("/selectOneSaleinfoVo/{saleId}")
    @ApiOperation("查询出库详情")
    @ApiImplicitParam(name="saleId",value="出库信息Id")
    public SaleinfoVo selectOneSaleinfoVo(@PathVariable("saleId") Long saleId){
        return saleinfoService.selectOneSaleinfoById(saleId);
    }

    @GetMapping("/clientCount/{pageNum}/{pageSize}")
    @ApiOperation("客户订单统计")
    @ApiImplicitParams({
            @ApiImplicitParam(name="pageNum",value="当前页码"),
            @ApiImplicitParam(name="pageSize",value="页面展示条数")
    })
    public PageUtil<ClientCollect> clientCount(@PathVariable("pageNum")Integer pageNum,
                                               @PathVariable("pageSize")Integer pageSize){
        PageUtil<ClientCollect> pageUtil = new PageUtil<>();
        pageUtil.setPageNum(pageNum);
        pageUtil.setPageSize(pageSize);
        return saleinfoService.clientCollect(pageUtil);
    }

    @PostMapping("/clientCountByInfo")
    @ApiOperation("查询客户订单统计信息")
    public PageUtil<ClientCollect> clientCountByInfo(SelectUtil selectUtil){
        return saleinfoService.clientCountByInfo(selectUtil);
    }
}
